<template>

  <section>
    <!--列表-->
    <el-table :data="pageInfo" highlight-current-row :v-loading="listLoading"
              style="width: 100%;">
      <el-table-column label="序号" type="index" width="60">
      </el-table-column>
      <el-table-column prop="name" label="店铺名称" width="200" sortable>
      </el-table-column>
      <el-table-column prop="tel" label="电话" width="120" sortable>
      </el-table-column>
      <el-table-column prop="address" label="店铺地址" width="120" sortable>
      </el-table-column>
      <el-table-column prop="registerTime" label="店铺创建时间" width="300" sortable>
      </el-table-column>
      <el-table-column prop="username" label="账号" width="120" sortable>
      </el-table-column>
      <el-table-column prop="password" label="密码" width="120" sortable>
      </el-table-column>
      <el-table-column prop="phone" label="电话" width="120" sortable>
      </el-table-column>
      <el-table-column prop="email" label="邮箱" width="200" sortable>
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <el-button type="success" size="small" @click="activeSuccess">确认激活</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-dialog title="审核" :visible.sync="ActiveFormVisible" :close-on-click-modal="false">

      <span>请点击确定激活</span>

      <div slot="footer" class="dialog-footer">
        <el-button @click.native="detailFormVisible = false">取消</el-button>
        <el-button type="success" @click.native="activeSuc">确定</el-button>
      </div>

    </el-dialog>


  </section>


</template>

<script>
import axios from "axios";

export default {
  name: "Active",
  data() {
    return {
      pageInfo:[],// 待激活店铺信息
      listLoading: false, // 列表加载
      ActiveFormVisible: false,// 确认激活弹框
    }
  },
  methods: {
    // 获取激活店铺信息
    getInfo() {
      let href=window.location.href
      // http://127.0.0.1:9001/#/active?code=
      let uuid=href.split("http://127.0.0.1:9001/#/active?code=")[1];
      axios.get("/shop/active/"+uuid).then(res => {
        if (res.status == 200) {
          console.log(res)
          // 成功
          this.pageInfo = [res.data.data]
        }
      }).catch(() => {

      })
    },
    // 确认激活弹框
    activeSuccess() {
      this.ActiveFormVisible = true
    },
    // 确认激活
    activeSuc() {
      let href=window.location.href
      // http://127.0.0.1:9001/#/active?code=
      let uuid=href.split("http://127.0.0.1:9001/#/active?code=")[1];
      axios.post("/shop/activeSuccess/"+uuid).then(res => {
        if (res.status == 200) {
          // 弹框消失
          this.ActiveFormVisible = false
          // 清除数据
          // this.pageInfo=[]
          // 激活成功
          this.$message.success("激活成功")
          // 跳转到登录页面
          this.$router.push("/login")
        }
      }).catch(() => {

      })

    }
  },
  mounted() {
    this.getInfo()
  }
}
</script>

<style scoped>

</style>